DEFINE CLASS databaseclass as Custom

	FUNCTION abrirconeccion
	
		OPEN DATABASE 'c:\fox\Grupo07\Data\db_Biblioteca.dbc'
		
	ENDFUNC
	
	FUNCTION cerrarconeccion
	
		CLOSE DATABASES
		
	ENDFUNC	

ENDDEFINE


DEFINE CLASS dataautores as databaseclass
	
	vapellido = ""
	vnombre = ""
	vidautor = 0
	
	FUNCTION insert as Boolean
		
		INSERT INTO autor (apellido, nombre) ;
		VALUES (this.vapellido, this.vnombre)
		
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION update AS Boolean
	
		update autor set ;
		apellido = this.vapellido, ;
		nombre = this.vnombre ;
		where idautor = this.vidautor
		
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION delete AS Boolean
	
		SET DELETED OFF
		delete from autor where idautor = this.vidautor
	
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC

	
	FUNCTION getone AS Boolean
		
		PARAMETERS bidautor
		select * from autor where idautor = bidautor into cursor curAutBuscado
		
		this.vapellido = curAutBuscado.apellido
		this.vnombre = curAutBuscado.nombre
		this.vidautor = curAutBuscado.idautor

		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION getall AS Boolean
		
		SELECT * FROM autor INTO CURSOR vcurautores
		
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
ENDDEFINE


DEFINE CLASS datasocios as databaseclass
	
	vapellido = ""
	vnombre = ""
	vemail = "" 
	vidsocio = 0
	vdomicilio = ""
	vnrosocio = 0
	vtelefono = ""
	
	FUNCTION insert AS Boolean
		
		INSERT INTO socio (apellido, nombre, email, domicilio, nrosocio,telefono) ;
		VALUES (this.vapellido, this.vnombre, this.vemail, this.vdomicilio, this.vnrosocio, this.vtelefono)
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	FUNCTION existesocio as Boolean
	PARAMETERS pnombre as String, papellido as string
	vexiste = .T.
	this.abrirconeccion()
	
	SELECT * FROM socio WHERE nombre = pnombre AND apellido = papellido INTO CURSOR curExiste
	
		IF _TALLY > 0 then
			vexiste = .T.
		ELSE
			vexiste = .F.
		ENDIF
	this.cerrarconeccion()
	RETURN vexiste
	ENDFUNC
	
	FUNCTION update AS Boolean
		
		update socio set ;
		apellido = this.vapellido, ;
		nombre = this.vnombre, ;
		email = this.vemail, ;
		domicilio = this.vdomicilio, ;
		nrosocio = this.vnrosocio, ;
		telefono = this.vtelefono ;
		where idsocio = this.vidsocio
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	endfunc
	
	
	FUNCTION delete AS Boolean
		
		PARAMETERS bidsocio
		delete from socio where idsocio = bidsocio
	
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
	
		SET DELETED ON
	
	ENDFUNC
	
	
	FUNCTION deleteall AS Boolean
	
		DELETE from socio 
	
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
		SET DELETED ON
	
	ENDFUNC
	
	
	FUNCTION getone as Boolean
		
		PARAMETERS bidsocio
		select * from socio where idsocio = bidsocio into cursor curSocBuscado
		
		this.vapellido = curSocBuscado.apellido
		this.vnombre = curSocBuscado.nombre
		this.vemail = curSocBuscado.email
		this.vidsocio = curSocBuscado.idsocio
		this.vdomicilio = curSocBuscado.domicilio
		this.vnrosocio = curSocBuscado.nrosocio
		this.vtelefono = curSocBuscado.telefono
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION getall as Boolean
		
		SELECT * FROM socio INTO CURSOR vcursocios
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION getmaxid as int
		
		SELECT socio
		CALCULATE MAX(idsocio) TO maxid
		RETURN maxid
		
	ENDFUNC

ENDDEFINE




DEFINE CLASS databiblioteca AS databaseclass

	vidbiblioteca = 0
	vnombre = ""

	FUNCTION insert AS Boolean
		
		INSERT INTO biblioteca (idbiblioteca, nombre) ;
		VALUES (this.vidbiblioteca, this.vnombre)
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION update AS Boolean
		
		update biblioteca set ;
		idbiblioteca = this.vidbiblioteca, ;
		nombre = this.vnombre, ;
				
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION delete AS Boolean
		
		PARAMETERS bidbiblioteca
		delete from biblioteca where idbiblioteca = bidbiblioteca
	
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
	
		SET DELETED ON
	
	ENDFUNC
	
	
	FUNCTION deleteall AS Boolean
	
		DELETE from biblioteca 
	
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
		SET DELETED ON
	
	ENDFUNC
	
	
	FUNCTION getone as Boolean
		
		PARAMETERS bidbiblioteca
		select * from biblioteca where idbiblioteca = bidbiblioteca into cursor curBiblioBuscada
		
		this.vidbiblioteca = curBiblioBuscada.idbiblioteca
		this.vnombre = curBiblioBuscada.nombre
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION getall as Boolean
		
		SELECT * FROM biblioteca INTO CURSOR vcurbiblioteca
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION getmaxid as int
		
		SELECT biblioteca
		CALCULATE MAX(idbiblioteca) TO maxid
		RETURN maxid
		
	ENDFUNC
	
ENDDEFINE




DEFINE CLASS dataeditorial AS databaseclass

	videditorial = 0
	vnombre = ""

	FUNCTION insert AS Boolean
		
		INSERT INTO editorial (ideditorial, nombre) ;
		VALUES (this.videditorial, this.vnombre)
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION update AS Boolean
		
		update editorial set ;
		ideditorial = this.videditorial, ;
		nombre = this.vnombre, ;
				
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION delete AS Boolean
		
		PARAMETERS bideditorial
		delete from editorial where ideditorial = bideditorial
	
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
	
		SET DELETED ON
	
	ENDFUNC
	
	
	FUNCTION deleteall AS Boolean
	
		DELETE from editorial 
	
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
		SET DELETED ON
	
	ENDFUNC
	
	
	FUNCTION getone as Boolean
		
		PARAMETERS bideditorial
		select * from editorial where ideditorial = bideditorial into cursor curEditorialBuscada
		
		this.videditorial = curEditorialBuscada.ideditorial
		this.vnombre = curEditorialBuscada.nombre
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION getall as Boolean
		
		SELECT * FROM editorial INTO CURSOR vcureditorial
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION getmaxid as int
		
		SELECT editorial
		CALCULATE MAX(ideditorial) TO maxid
		RETURN maxid
		
	ENDFUNC
	
ENDDEFINE




DEFINE CLASS dataejemplar AS databaseclass

	videjemplar = 0
	vidbiblioteca = 0
	vidlibro = 0
	vnroejemplar = 0

	FUNCTION insert AS Boolean
		
		INSERT INTO ejemplar (idejemplar, idbiblioteca, idlibro, nroejemplar) ;
		VALUES (this.videjemplar, this.idbiblioteca, this.idlibro, this.vnroejemplar)
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION update AS Boolean
		
		update ejemplar set ;
		idejemplar = this.videjemplar, ;
		idbiblioteca = this.vidbiblioteca;
		idlibro = this.vidlibro;
		nroejemplar = this.vnroejemplar ;
				
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION delete AS Boolean
		
		PARAMETERS bidejemplar
		delete from ejemplar where idejemplar = bidejemplar
	
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
	
		SET DELETED ON
	
	ENDFUNC
	
	
	FUNCTION deleteall AS Boolean
	
		DELETE from ejemplar 
	
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
		SET DELETED ON
	
	ENDFUNC
	
	
	FUNCTION getone as Boolean
		
		PARAMETERS bidejemplar
		select * from ejemplar where idejemplar = bidejemplar into cursor curEjemplarBuscado
		
		this.videjemplar = curEjemplarBuscado.idejemplar
		this.vidbiblioteca = curEjemplarBuscado.idbiblioteca
		this.vidlibro = curEjemplarBuscado.idlibro
		this.vnroejemplar = curEjemplarBuscado.nroejemplar
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION getall as Boolean
		
		SELECT * FROM ejemplar INTO CURSOR vcurejemplar
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION getmaxid as int
		
		SELECT ejemplar
		CALCULATE MAX(idejemplar) TO maxid
		RETURN maxid
		
	ENDFUNC
	
ENDDEFINE




DEFINE CLASS dataestanteria AS databaseclass

	videstanteria = 0
	
	FUNCTION insert AS Boolean
		
		INSERT INTO estanteria (idestanteria) ;
		VALUES (this.videstanteria)
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION update AS Boolean
		
		update estanteria set ;
		idestanteria = this.videstanteria, ;
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION delete AS Boolean
		
		PARAMETERS bidestanteria
		delete from estanteria where idestanteria = bidestanteria
	
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
	
		SET DELETED ON
	
	ENDFUNC
	
	
	FUNCTION deleteall AS Boolean
	
		DELETE from estanteria 
	
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
		SET DELETED ON
	
	ENDFUNC
	
	
	FUNCTION getone as Boolean
		
		PARAMETERS bidestanteria
		select * from estanteria where idestanteria = bidestanteria into cursor curEstanteriaBuscada
		
		this.videstanteria = curEstanteriaBuscada.idestanteria
				
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION getall as Boolean
		
		SELECT * FROM estanteria INTO CURSOR vcurestanteria
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION getmaxid as int
		
		SELECT estanteria
		CALCULATE MAX(idestanteria) TO maxid
		RETURN maxid
		
	ENDFUNC
	
ENDDEFINE




DEFINE CLASS dataidioma AS databaseclass

	vididioma = 0
	vdenominacion = ""

	FUNCTION insert AS Boolean
		
		INSERT INTO idioma (ididioma, denominacion) ;
		VALUES (this.vididioma, this.vdenominacion)
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION update AS Boolean
		
		update idioma set ;
		ididioma = this.vididioma, ;
		denominacion = this.vdenominacion, ;
				
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION delete AS Boolean
		
		PARAMETERS bididioma
		delete from idioma where ididioma = bididioma
	
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
	
		SET DELETED ON
	
	ENDFUNC
	
	
	FUNCTION deleteall AS Boolean
	
		DELETE from idioma 
	
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
		SET DELETED ON
	
	ENDFUNC
	
	
	FUNCTION getone as Boolean
		
		PARAMETERS bididioma
		select * from idioma where ididioma = bididioma into cursor curIdiomaBuscado
		
		this.vididioma = curIdiomaBuscado.ididioma
		this.vdenominacion = curIdiomaBuscado.denominacion
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION getall as Boolean
		
		SELECT * FROM idioma INTO CURSOR vcuridioma
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION getmaxid as int
		
		SELECT idioma
		CALCULATE MAX(ididioma) TO maxid
		RETURN maxid
		
	ENDFUNC
	
ENDDEFINE




DEFINE CLASS datalibro AS databaseclass

	vidlibro = 0
	vfedicion = ""
	vidautor = 0
	videditorial = 0
	videstanteria = 0
	vididioma = 0
	vcantmaxdias = 0
	vidtema = 0
	visbn = 0
	vnroedicion = 0
	vtitulo = ""

	FUNCTION insert AS Boolean
		
		INSERT INTO libro (idlibro, fedicion, idautor, ideditorial, idestanteria, ididioma, cantmaxdias, idtema, isbn, nroedicion, titulo) ;
		VALUES (this.vidlibro, this.vfedicion, this.vidautor, this.videditorial, this.videstanteria, this.vididioma, this.vcantmaxdias, this.vidtema, this.visbn, this.vnroedicion, this.vtitulo)
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION update AS Boolean
		
		update libro set ;
		idlibro = this.vidbiblioteca, ;
		fedicion = this.vfedicion, ;
		idautor = this.vidautor, ;
		ideditorial = this.videditorial, ;
		idestanteria = this.videstanteria, ;
		ididioma = this.vididioma, ;
		cantmaxdias = this.vcantmaxdias, ;
		idtema = this.vidtema, ;
		isbn = this.visbn, ;
		nroedicion = this.vnroedicion, ;
		titulo = this.vtitulo, ;
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION delete AS Boolean
		
		PARAMETERS bidlibro
		delete from libro where idlibro = bidlibro
	
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
	
		SET DELETED ON
	
	ENDFUNC
	
	
	FUNCTION deleteall AS Boolean
	
		DELETE from libro 
	
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
		SET DELETED ON
	
	ENDFUNC
	
	
	FUNCTION getone as Boolean
		
		PARAMETERS bidlibro
		select * from libro where idlibro = bidlibro into cursor curLibroBuscado
		
		this.vidlibro = curLibroBuscado.idlibro
		this.vfedicion = curLibroBuscado.fedicion
		this.vidautor = curLibroBuscado.idautor
		this.videditorial = curLibroBuscado.ideditorial
		this.videstanteria = curLibroBuscado.idestanteria
		this.vididioma = curLibroBuscado.ididioma
		this.vcantmaxdias = curLibroBuscado.cantmaxdias
		this.vidtema = curLibroBuscado.idtema
		this.visbn = curLibroBuscado.isbn
		this.vnroedicion = curLibroBuscado.nroedicion
		this.vtitulo = curLibroBuscado.titulo
		
			
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION getall as Boolean
		
		SELECT * FROM libro INTO CURSOR vcurlibro
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION getmaxid as int
		
		SELECT libro
		CALCULATE MAX(idlibro) TO maxid
		RETURN maxid
		
	ENDFUNC
	
ENDDEFINE




DEFINE CLASS datapolprestamo AS databaseclass

	vidpolpres = 0
	vidbiblioteca = 0
	vcantlibmax = 0
	vfechavig = ""
	

	FUNCTION insert AS Boolean
		
		INSERT INTO idioma (idpolpres, idbiblioteca, cantlibmax, fechavig) ;
		VALUES (this.vidpolpres, this.vidbiblioteca, this.vcantlibmax, this.vfechavig)
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION update AS Boolean
		
		update politicaprestamo set ;
		idpolpres = this.vidpolpres, ;
		idbiblioteca = this.vidbiblioteca, ;
		cantlibmax = this.vcantlibmax, ;
		fechavig = this.vfechavig, ;
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION delete AS Boolean
		
		PARAMETERS bidpolpres
		delete from politicaprestamo where idpolpres = bidpolpres
	
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
	
		SET DELETED ON
	
	ENDFUNC
	
	
	FUNCTION deleteall AS Boolean
	
		DELETE from politicaprestamo 
	
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
		SET DELETED ON
	
	ENDFUNC
	
	
	FUNCTION getone as Boolean
		
		PARAMETERS bidpolpres
		select * from politicaprestamo where idpolpres = bidpolpres into cursor curPolPresBuscada
		
		this.vidpolpres = curPolPresBuscada.idpolpres
		this.vidbiblioteca = curPolPresBuscada.idbiblioteca
		this.vcantlibmax = curPolPresBuscada.cantlibmax
		this.vfechavig = curPolPresBuscada.fechavig
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION getall as Boolean
		
		SELECT * FROM politicaprestamo INTO CURSOR vCurPolPres
		
		IF _TALLY > 0 then
			RETURN .T.
		ELSE
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION getmaxid as int
		
		SELECT politicaprestamo
		CALCULATE MAX(idpolpres) TO maxid
		RETURN maxid
		
	ENDFUNC
	
ENDDEFINE





DEFINE CLASS datapolsancion as databaseclass
	
	vidpolsan = 0
	vidbiblioteca = 0
	vfechavig = ""
	vcantdias = 0
	vcantdsam = 0
	
	
	
	FUNCTION insert as Boolean
		
		INSERT INTO politicasancion (idpolsan, idbiblioteca, fechavig, cantdias, cantdsam) ;
		VALUES (this.vidpolsan, this.vidbiblioteca, this.vfechavig, this.vcantdias, this.cantdsam)
		
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION update AS Boolean
	
		update politicasancion set ;
		
			idbiblioteca = this.vidbiblioteca, ;
			fechavig = this.vfechavig, ;
			cantdias = this.vcantdias, ;
			cantdsam = this.vcantdsam
		
		where idpolpres = this.vidpolpres
		
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION delete AS Boolean
	
		SET DELETED OFF
		delete from politicasancion where idpolsan = this.vidpolsan
	
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC

	
	FUNCTION getone AS Boolean
		
		PARAMETERS bidpolsan
		select * from politicasancion where idpolsan = bidpolsan into cursor curPolSanBuscada
		
		this.vidpolsan = curPolSanBuscada.idpolsan
		this.vidbiblioteca = curPolSanBuscada.idbiblioteca
		this.vcantdias = curPolSanBuscada.cantdias
		this.vcantdsam = curPolSanBuscada.cantdsam
		this.vfechavig = curPolSanBuscada.fechavig
		
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION getall AS Boolean
		
		SELECT * FROM politicasancion INTO CURSOR vCurPolSan
		
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC

ENDDEFINE





DEFINE CLASS dataprestamo as databaseclass
	
	vfecha = ""
	vfechadevre = ""
	vfechadevsep = ""
	vhora = ""
	vidsocio = ""
	vnumero = ""
	
	
	FUNCTION insert as Boolean
		
		INSERT INTO prestamo (fecha, fechadevre, fechadevsep, hora, idsocio, numero) ;
		VALUES (this.vfecha, this.vfechadevre, this.vfechadevsep, this.vhora, this.vidsocio, this.vnumero)
		
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION update AS Boolean
	
		update prestamo set ;
			fecha = this.vfecha, ;
			fechadevre = this.vfechadevre, ;
			fechadevsep = this.vfechadevsep, ;
			hora = this.vhora, ;
			idsocio = this.vidsocio, ;
		where numero = this.vnumero
		
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION delete AS Boolean
	
		SET DELETED OFF
		delete from prestamo where numero = this.vnumero
	
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC

	
	FUNCTION getone AS Boolean
		
		PARAMETERS bnumero
		select * from prestamo where numero = bnumero into cursor curPrestamoBuscado
		
		this.vfecha = curPrestamoBuscado.fecha
		this.vfechadevre = curPrestamoBuscado.fechadevre
		this.vfechadevsep = curPrestamoBuscado.fechadevsep
		this.vhora = curPrestamoBuscado.hora
		this.vidsocio = curPrestamoBuscado.idsocio
		this.vnumero = curPrestamoBuscado.numero

		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION getall AS Boolean
		
		SELECT * FROM prestamo INTO CURSOR vCurPrestamo
		
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC

ENDDEFINE




DEFINE CLASS dataprestejemplar as databaseclass
	
	videjemplar = 0
	vidpresejem = 0
	vidprestamo = 0
	
	
	FUNCTION insert as Boolean
		
		INSERT INTO prestamoejemplar (idejemplar, idpresejem, idprestamo) ;
		VALUES (this.videjemplar, this.vidpresejem, this.vidprestamo)
		
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION update AS Boolean
	
		update prestamoejemplar set ;
		idejemplar = this.videjemplar, ;
		idpresejem = this.vidpresejem, ;
		idprestamo = this.vidprestamo, ;
		where idpresejem = this.vidpresejem
		
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION delete AS Boolean
	
		SET DELETED OFF
		delete from prestamoejemplar where idpresejem = this.vidpresejem
	
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC

	
	FUNCTION getone AS Boolean
		
		PARAMETERS bidpresejem
		select * from prestamoejemplar where idpresejem = bidpresejem into cursor curPresEjemBuscado
		
		this.vidpresejem = curPresEjemBuscado.idpresejem
		this.vidprestamo = curPresEjemBuscado.idprestamo
		this.videjemplar = curPresEjemBuscado.idejemplar
		
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION getall AS Boolean
		
		SELECT * FROM prestamoejemplar INTO CURSOR vCurPresEjem
		
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC

ENDDEFINE





DEFINE CLASS datasancion as databaseclass
	
	vdias = 0
	vfecha = 0
	vidsancion = 0
	vidsocio = 0
	
	
	FUNCTION insert as Boolean
		
		INSERT INTO sancion (dias, fecha, idsancion, idsocio) ;
		VALUES (this.vdias, this.vfecha, this.vidsancion, this.vidsocio)
		
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION update AS Boolean
	
		update sancion set ;
		
		dias = this.vdias, ;
		fecha = this.vfecha, ;
		idsancion = this.vidsancion, ;
		idsocio = this.vidsocio, ;
		where idsancion = this.vidsancion
		
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION delete AS Boolean
	
		SET DELETED OFF
		delete from sancion where idsancion = this.vidsancion
	
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC

	
	FUNCTION getone AS Boolean
		
		PARAMETERS bidsancion
		select * from sancion where idsancion = bidsancion into cursor curSancionBuscada
		
		
		this.vidsancion = curSancionBuscada.idsancion
		this.vfecha = curSancionBuscada.fecha
		this.vdias = curSancionBuscada.dias
		this.vidsocio = curSancionBuscada.idsocio
		
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION getall AS Boolean
		
		SELECT * FROM sancion INTO CURSOR vCurSancion
		
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC

ENDDEFINE




DEFINE CLASS datatema as databaseclass
	
	vidtema = 0
	vnombre = ""
	
	
	FUNCTION insert as Boolean
		
		INSERT INTO tema (idtema, nombre) ;
		VALUES (this.vidtema, this.vnombre)
		
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION update AS Boolean
	
		update tema set ;
		idtema = this.vidtema, ;
		nombre = this.vnombre ;
		where idtema = this.vidtema
		
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION delete AS Boolean
	
		SET DELETED OFF
		delete from tema where idtema = this.vidtema
	
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC

	
	FUNCTION getone AS Boolean
		
		PARAMETERS bidtema
		select * from tema where idtema = bidtema into cursor curTemaBuscado
		
		this.vidtema = curTemaBuscado.idtema
		this.vnombre = curTemaBuscado.nombre
		
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC
	
	
	FUNCTION getall AS Boolean
		
		SELECT * FROM tema INTO CURSOR vCurTema
		
		IF _Tally > 0 then
			RETURN .T.
		ELSE 
			RETURN .F.
		ENDIF
		
	ENDFUNC

ENDDEFINE